class Solution {
    public boolean canJump(int[] nums) {
        int i = 0;
        int cover = nums[0];
        while (i <= cover) {
            cover = Math.max(cover, i + nums[i]);
            if (cover >= nums.length-1)
                return true;
            i++;
        }
        return false;
    }
}